/**   
 * @Title: SportteryFootballNoFilterAgainstInfoCommunicater.java 
 * @Package com.esun.rabbit2.communicaters.sportteryfootball 
 * @Description: (无筛选对阵信息列表获取) 
 * @author: City Jiangsy@500wan.com   
 * @date: 2011-9-5 下午02:39:00  
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.sportteryfootball;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Key;
import com.esun.model.sportteryfootball.SportteryFootballAgainstInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.HashMapUtil;

/**
 * @ClassName: SportteryFootballNoFilterAgainstInfoCommunicater
 * @Description: (无筛选对阵信息列表获取)
 * @author: City Jiangsy@500wan.com
 * @date: 2011-9-5 下午02:39:00
 * 
 */
public class SportteryFootballNoFilterAgainstInfoCommunicater extends ServerCommunicater {
	private String msgServer = ""; // 服务器信息
	private boolean isSucceed = false;

	private int type;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	/**
	 * @Title: isGetInfoSucceed
	 * @Description: TODO(这里用一句话描述这个方法的作用)
	 * @param: @param type 1-只有过关 2-多串过关
	 * @param: @param count 大于0则返回对应的条数，小于0或者不传则返回全部条数
	 * @param: @return 是否通信成功
	 * @param: @throws ClientProtocolException
	 * @param: @throws IOException
	 * @param: @throws ParserConfigurationException
	 * @param: @throws SAXException 设定文件
	 */
	public boolean isGetInfoSucceed(int type, int count) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		this.type = type;

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(HashMapUtil.getMapItem(BussinessCode.PASER_MID, BussinessCode.MID_SPORTTERFOOTBALL_AGAINSTINFO_NOFILTER_VER_TWO));
		list.add(HashMapUtil.getMapItem(Key.KEY_TYPE, Integer.toString(type)));
		list.add(HashMapUtil.getMapItem(Key.KEY_NUM, String.valueOf(count)));
		// 写入服务器返回信息
		super.getServerResponse(list, true);
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			isSucceed = true;
		} else {
			isSucceed = false;
		}

		return isSucceed;
	}

	public ArrayList<SportteryFootballAgainstInfo> getAgainstInfoList() {

		ArrayList<SportteryFootballAgainstInfo> listSportteryFootballAgainstInfos = new ArrayList<SportteryFootballAgainstInfo>();

		if (super.getListResult() != null) {
			for (int i = 0; i < super.getListResult().size(); i++) {
				SportteryFootballAgainstInfo sportteryFootballAgainstInfo = new SportteryFootballAgainstInfo();
				sportteryFootballAgainstInfo.setMatchNum(super.getListResult().get(i).get(Key.KEY_MATCHNUM));
				sportteryFootballAgainstInfo.setMatchNumDate(super.getListResult().get(i).get(Key.KEY_MATCHNUMDATE));
				sportteryFootballAgainstInfo.setDayOfWeek(super.getListResult().get(i).get(Key.KEY_DAYOFWEEK));
				sportteryFootballAgainstInfo.setId(super.getListResult().get(i).get(Key.KEY_ID));
				sportteryFootballAgainstInfo.setSimpleLeague(super.getListResult().get(i).get(Key.KEY_SIMPLELEAGUE));
				sportteryFootballAgainstInfo.setHomeSxName(super.getListResult().get(i).get(Key.KEY_HOMESXNAME));
				sportteryFootballAgainstInfo.setAwaySxName(super.getListResult().get(i).get(Key.KEY_AWAYSXNAME));
				sportteryFootballAgainstInfo.setPtggEndTime(super.getListResult().get(i).get(Key.KEY_PTGGENDTIME));
				sportteryFootballAgainstInfo.setxId(super.getListResult().get(i).get(Key.KEY_XID));
				sportteryFootballAgainstInfo.setProcessName(super.getListResult().get(i).get(Key.KEY_PROCESSNAME));

				if (type == 1 || type == 2) {
					sportteryFootballAgainstInfo.setWin(super.getListResult().get(i).get(Key.KEY_WIN));
					sportteryFootballAgainstInfo.setLost(super.getListResult().get(i).get(Key.KEY_LOST));
					sportteryFootballAgainstInfo.setDraw(super.getListResult().get(i).get(Key.KEY_DRAW));
					sportteryFootballAgainstInfo.setRangqiu(super.getListResult().get(i).get(Key.KEY_RANGQIU));

				} else if (type == 3 || type == 4) {
					sportteryFootballAgainstInfo.setsZero(super.getListResult().get(i).get(Key.KEY_S0));
					sportteryFootballAgainstInfo.setsOne(super.getListResult().get(i).get(Key.KEY_S1));
					sportteryFootballAgainstInfo.setsTwo(super.getListResult().get(i).get(Key.KEY_S2));
					sportteryFootballAgainstInfo.setsThree(super.getListResult().get(i).get(Key.KEY_S3));
					sportteryFootballAgainstInfo.setsFour(super.getListResult().get(i).get(Key.KEY_S4));
					sportteryFootballAgainstInfo.setsFive(super.getListResult().get(i).get(Key.KEY_S5));
					sportteryFootballAgainstInfo.setsSix(super.getListResult().get(i).get(Key.KEY_S6));
					sportteryFootballAgainstInfo.setsSeven(super.getListResult().get(i).get(Key.KEY_S7));

				} else if (type == 5 || type == 6) {
					updataScoreInfo(sportteryFootballAgainstInfo, i);

				} else if (type == 7 || type == 8) {
					sportteryFootballAgainstInfo.setAa(super.getListResult().get(i).get(Key.KEY_AA));
					sportteryFootballAgainstInfo.setAb(super.getListResult().get(i).get(Key.KEY_AB));
					sportteryFootballAgainstInfo.setAc(super.getListResult().get(i).get(Key.KEY_AC));
					sportteryFootballAgainstInfo.setBa(super.getListResult().get(i).get(Key.KEY_BA));
					sportteryFootballAgainstInfo.setBb(super.getListResult().get(i).get(Key.KEY_BB));
					sportteryFootballAgainstInfo.setBc(super.getListResult().get(i).get(Key.KEY_BC));
					sportteryFootballAgainstInfo.setCa(super.getListResult().get(i).get(Key.KEY_CA));
					sportteryFootballAgainstInfo.setCb(super.getListResult().get(i).get(Key.KEY_CB));
					sportteryFootballAgainstInfo.setCc(super.getListResult().get(i).get(Key.KEY_CC));

				} else {

				}
				listSportteryFootballAgainstInfos.add(sportteryFootballAgainstInfo);
			}
		}

		return listSportteryFootballAgainstInfos;
	}

	/**
	 * @Title: updataScoreInfo
	 * @Description: 导入type为比分时的数据
	 * @param: @param sportteryFootballAgainstInfo
	 * @param: @param i 设定文件
	 * @return: void 返回类型
	 * @throws
	 */
	private void updataScoreInfo(SportteryFootballAgainstInfo sportteryFootballAgainstInfo, int i) {
		sportteryFootballAgainstInfo.setaOneZero(super.getListResult().get(i).get(Key.KEY_A10));
		sportteryFootballAgainstInfo.setaTwoZero(super.getListResult().get(i).get(Key.KEY_A20));
		sportteryFootballAgainstInfo.setaTwoOne(super.getListResult().get(i).get(Key.KEY_A21));
		sportteryFootballAgainstInfo.setaThreeZero(super.getListResult().get(i).get(Key.KEY_A30));
		sportteryFootballAgainstInfo.setaThreeOne(super.getListResult().get(i).get(Key.KEY_A31));
		sportteryFootballAgainstInfo.setaThreeTwo(super.getListResult().get(i).get(Key.KEY_A32));
		sportteryFootballAgainstInfo.setaFourZero(super.getListResult().get(i).get(Key.KEY_A40));
		sportteryFootballAgainstInfo.setaFourOne(super.getListResult().get(i).get(Key.KEY_A41));
		sportteryFootballAgainstInfo.setaFourTwo(super.getListResult().get(i).get(Key.KEY_A42));
		sportteryFootballAgainstInfo.setaFiveZero(super.getListResult().get(i).get(Key.KEY_A50));
		sportteryFootballAgainstInfo.setaFiveOne(super.getListResult().get(i).get(Key.KEY_A51));
		sportteryFootballAgainstInfo.setaFiveTwo(super.getListResult().get(i).get(Key.KEY_A52));
		sportteryFootballAgainstInfo.setaOther(super.getListResult().get(i).get(Key.KEY_AOTHER));

		sportteryFootballAgainstInfo.setcZeroZero(super.getListResult().get(i).get(Key.KEY_C00));
		sportteryFootballAgainstInfo.setcOneOne(super.getListResult().get(i).get(Key.KEY_C11));
		sportteryFootballAgainstInfo.setcTwoTwo(super.getListResult().get(i).get(Key.KEY_C22));
		sportteryFootballAgainstInfo.setcThreeThree(super.getListResult().get(i).get(Key.KEY_C33));
		sportteryFootballAgainstInfo.setcOther(super.getListResult().get(i).get(Key.KEY_COTHER));

		sportteryFootballAgainstInfo.setbOneZero(super.getListResult().get(i).get(Key.KEY_B10));
		sportteryFootballAgainstInfo.setbTwoZero(super.getListResult().get(i).get(Key.KEY_B20));
		sportteryFootballAgainstInfo.setbTwoOne(super.getListResult().get(i).get(Key.KEY_B21));
		sportteryFootballAgainstInfo.setbThreeZero(super.getListResult().get(i).get(Key.KEY_B30));
		sportteryFootballAgainstInfo.setbThreeOne(super.getListResult().get(i).get(Key.KEY_B31));
		sportteryFootballAgainstInfo.setbThreeTwo(super.getListResult().get(i).get(Key.KEY_B32));
		sportteryFootballAgainstInfo.setbFourZero(super.getListResult().get(i).get(Key.KEY_B40));
		sportteryFootballAgainstInfo.setbFourOne(super.getListResult().get(i).get(Key.KEY_B41));
		sportteryFootballAgainstInfo.setbFourTwo(super.getListResult().get(i).get(Key.KEY_B42));
		sportteryFootballAgainstInfo.setbFiveZero(super.getListResult().get(i).get(Key.KEY_B50));
		sportteryFootballAgainstInfo.setbFiveOne(super.getListResult().get(i).get(Key.KEY_B51));
		sportteryFootballAgainstInfo.setbFiveTwo(super.getListResult().get(i).get(Key.KEY_B52));
		sportteryFootballAgainstInfo.setbOther(super.getListResult().get(i).get(Key.KEY_BOTHER));

	}

}
